//
//  NhacVietViewController.m
//  NhomTuan
//
//  Created by Buffalo on 1/30/15.
//  Copyright (c) 2015 t3h. All rights reserved.
//

#import "NhacVietViewController.h"
#import "AppManager.h"
#import "NhacVietTableViewCell.h"
#import "LoiNhacViewController.h"
@interface NhacVietViewController ()

@end

@implementation NhacVietViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated {
    self.tableNhacViet.delegate = self;
    self.tableNhacViet.dataSource = self;
    [self.navigationController.navigationBar setBarTintColor:[AppUtils greenColor]];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    UIImage *image = [UIImage imageNamed:@"img_logo.png"];
    UIImageView *titleImg = [[UIImageView alloc] initWithImage:image];
    [self.navigationController.navigationBar.topItem setTitleView:titleImg];
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [AppManager defaultmanager].viSongList.count;
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    NSIndexPath *index = [self.tableNhacViet indexPathForSelectedRow];
    LoiNhacViewController *loiNhacView = (LoiNhacViewController *)segue.destinationViewController;
    loiNhacView.song = [[Song alloc] initSongInArray:[AppManager defaultmanager].viSongList atIndex:index.row];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *cellId = @"nhac_viet_cell_id";
    NhacVietTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    Song *viSong = [[Song alloc] initSongInArray:[AppManager defaultmanager].viSongList atIndex:indexPath.row];

    cell.lblSongLyrics.text = viSong.lyrics;
    cell.lblSongName.text = viSong.name;
    cell.lblSongCode.text = viSong.code;
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
